package com.lg.okframe.base;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lg.okframe.study.communication.FunctionManager;

/**
 * Created by LG on 2018/7/31.
 */

public abstract class BaseFragment extends Fragment {
    public FunctionManager functionManager;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        int viewID = setView();
        View inflate = View.inflate(container.getContext(), viewID, null);
        initView(inflate, container.getContext());
        initData(savedInstanceState, container.getContext());
        return inflate;
    }


    public abstract void initData(Bundle savedInstanceState, Context context);

    public abstract void initView(View view, Context context);

    public abstract int setView();

    /**
     * 打开新的ac
     *
     * @param tosActivity
     */
    public void ToStartActivity(Class tosActivity) {
        Intent intent = new Intent(getActivity(), tosActivity);
        startActivity(intent);
    }

    public FunctionManager getFunctionManager() {
        return functionManager;
    }

    public void setFunctionManager(FunctionManager functionManager) {
        this.functionManager = functionManager;
    }
}
